#ifndef VEHICLE_H
#define VEHICLE_H

#include <iostream>
#include <vector>
#include "btBulletDynamicsCommon.h"

struct VehicleDescription
{
	btVector3 mVehicleInitialPosition;
	btVector3 mVehicleBodySize;
	btVector3 mVehicleCoordinateSystem;
	btVector3 mWheelDirection;
	btVector3 mWheelAxle;
	btVector3 mFrontLeftWheelOffset;
	btVector3 mFrontRightWheelOffset;
	btVector3 mRearLeftWheelOffset;
	btVector3 mRearRightWheelOffset;
	float mVehicleMass;
	float mSuspensionStiffness;
	float mSuspensionRestLength;
	float mWheelsDampingRelaxation;
	float mWheelsDampingCompression;
	float mWheelFriction;
	float mWheelRadius;
	float mFrictionSlip;
	float mRollInfluence;
	float mMaxEngineForce;
	float mMaxBreakingForce;
	float mMaxSteeringAngle;
};

class Vehicle
{
public:
	enum SteeringDirection {STEER_RIGHT, STEER_LEFT, STEER_NONE};

	Vehicle(VehicleDescription& desc, btDynamicsWorld* simWorld, std::vector<btRigidBody *>& bodies);
	~Vehicle();

	void pressGasPadel();
	void releaseGasPadel();
	void pressBreakPadel();
	void releaseBreakPadel();
	void setSteerDirection(SteeringDirection direction);
	void drive();
	int getWheelCount();
	float getWheelMatrix(float* mat, int i);

private:
	enum {FRONT_L, FRONT_R, REAR_L, REAR_R};

	btVehicleRaycaster* m_caster;
	btRaycastVehicle* m_vehicle;
	btRaycastVehicle::btVehicleTuning m_tuning;

	SteeringDirection m_currentSteeringDirection;

	float m_engineForce;
	float m_breakingForce;
	float m_steeringAngle;
	float m_maxEngineForce;
	float m_maxBreakingForce;
	float m_maxSteeringAngle;

	bool m_gasPadelPressed;
	bool m_breakPadelPressed;
};

#endif